package findContinuousSequence;

import java.util.*;

public class Solution {
    public int[][] findContinuousSequence(int target) {
        // 思路 双指针
        // 和为target
        List<int[]>list = new ArrayList<>();
        int r = 2,l = 1;
        while (l<r&&r<target){
            int sum = (l + r) * (r - l + 1) / 2;
            if(sum>target){
                l++;
            }else if(sum<target){
                r++;
            }else {
                int[] res = new int[r-l+1];
                for (int i = l; i <=r ; i++) {
                    res[i-l] = i;
                }
                list.add(res);
            }
        }
        return list.toArray(new int[list.size()][]);
    }
}
